import useLoginStore from '@/stores/login/login'
import { ElMessage } from 'element-plus'

// 判断请求状态
export function iscode(res: any, isShowMessage = false) {
  if (res.code == 0) {
    isShowMessage && ElMessage({ message: res.message, type: 'success' }) // 是否使用默认提示
    return true
  } else if (res.code == 100001) {
    ElMessage({ message: res.message, type: 'error' })
    // 登录过期
    const loginStore = useLoginStore()
    loginStore.logoutAction()
  } else {
    console.log(res)
    ElMessage({ message: res.message, type: 'error' })
    return false
  }
}
